"""

"""

from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.progressbar import ProgressBar
from kivy.clock import Clock

class ProgressDisplay(BoxLayout):
    """"""
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.orientation = 'vertical'
        self.spacing = 10
        self.padding = 20
        
        self._build_ui()
    
    def _build_ui(self):
        """"""
        # 
        self.status_label = Label(
            text="Ready to start processing...",
            size_hint_y=None,
            height=40,
            font_size=16
        )
        self.add_widget(self.status_label)
        
        # 
        self.progress_bar = ProgressBar(
            max=100,
            value=0,
            size_hint_y=None,
            height=30
        )
        self.add_widget(self.progress_bar)
        
        # 
        self.percent_label = Label(
            text="0%",
            size_hint_y=None,
            height=30,
            font_size=14,
            halign='center'
        )
        self.add_widget(self.percent_label)
        
        # 
        self.detail_label = Label(
            text="",
            size_hint_y=None,
            height=60,
            font_size=12,
            text_size=(None, None),
            halign='center'
        )
        self.add_widget(self.detail_label)
    
    def update_progress(self, value, status="", detail=""):
        """"""
        def update_ui(dt):
            self.progress_bar.value = value
            self.percent_label.text = f"{value:.1f}%"
            
            if status:
                self.status_label.text = status
            
            if detail:
                self.detail_label.text = detail
                # 
                self.detail_label.text_size = (self.detail_label.width, None)
        
        Clock.schedule_once(update_ui)
    
    def reset(self):
        """"""
        self.update_progress(0, "Ready to start processing...", "")